package com.dinadi.yidi.ui.activity;


import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.dinadi.yidi.R;
import com.dinadi.yidi.base.BaseActivity;

/**
 * author: JiaYu.He Date: 2016-04-15 Time: 13:31
 */
public class UserUnderstandingActivity extends BaseActivity {
	private WebView helpWebView;
	private View view;

	@Override
	protected View getLayout() {
		view = LayoutInflater.from(UserUnderstandingActivity.this).inflate(R.layout.activity_use_help, null);
		return view;
	}

	@Override
	protected void noWifiRefresh() {

	}

	@Override
	protected void initView() {
		changePager(2);
		helpWebView = (WebView) findViewById(R.id.activity_help_web);
		// 覆盖WebView默认使用第三方或系统默认浏览器打开网页的行为，使网页用WebView打开
		helpWebView.setWebViewClient(new WebViewClient() {
			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				// 返回值是true的时候控制去WebView打开，为false调用系统浏览器或第三方浏览器
				view.loadUrl(url);
				return true;
			}
		});
		helpWebView.getSettings().setJavaScriptEnabled(true);

	}

	@Override
	protected void initListener() {

	}

	@Override
	protected void initData() {
		helpWebView.loadUrl("http://yididesign.cn/privacy.html");
	}

	@Override
	protected void clickEvent(View v) {


	}
	@Override
	// 设置回退
	// 覆盖Activity类的onKeyDown(int keyCoder,KeyEvent event)方法
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if ((keyCode == KeyEvent.KEYCODE_BACK) && helpWebView.canGoBack()) {
			helpWebView.goBack(); // goBack()表示返回WebView的上一页面
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

}
